// pages/index/secondPage.js
const app = getApp();
const util = require("../../../../utils/util");
var optionsTitle = "";
Page({

    /**
     * 页面的初始数据
     */
    data: {
        name: ""
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        optionsTitle = decodeURIComponent(options.title);
        let id = options.id;
        util.getUrl(app.globalData.url).then(res => this.init(id));
    },
    init(id) {
        let $secondPageAllServer = {
            ac: "allServer",
            flag: "getServer",
            city: 'sz',
            type: app.globalData.platform,
            id
        };
        util.bstrequest('index.php', $secondPageAllServer, "POST").then(res => {
            let allServer = JSON.parse(JSON.stringify(res.data.allServer));
            if (res.data.name)
                wx.setNavigationBarTitle({
                    title: res.data.name,
                });
            else
                wx.setNavigationBarTitle({
                    title: optionsTitle,
                });
            this.setData({
                allServer,
            });
        });
    },
    secondPage2Next(e) {
        let index1 = e.currentTarget.dataset.index1;
        let index2 = e.currentTarget.dataset.index2;
        let data = this.data.allServer[index1].child[index2];
        if (data.ser_link_method != '0') {
            util.navTest(data);
            util.clickNumber(data.id);
        }
    },
    onShareAppMessage() {
        return {
            imageUrl: "http://imgbdb3.bendibao.com/xcxbdb/file/20212/9/20210209161843_68677.jpg"
        }
    },

    // 分享朋友圈
    onShareTimeline: function() {
        return {
            title: "本地宝",
            imageUrl: "http://imgbdb3.bendibao.com/xcxbdb/file/20212/9/20210209161843_68677.jpg",
            query: { title: "办事资格测试", id: 2351 },
        }
    },
});